package tr.edu.metu.is.mega.client.service;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

/**
 * GWT service for reading and returning file contents on the disk.
 */
@RemoteServiceRelativePath("../GwtFileService")
public interface GwtFileService extends RemoteService {

    /**
     * Utility class for simplifying access to the instance of async service.
     */
    public static class Util {

        private static GwtFileServiceAsync instance;

        /**
         * Returns singleton service instance.
         * 
         * @return singleton service instance
         */
        public static GwtFileServiceAsync getInstance() {
            if (instance == null) {
                instance = GWT.create(GwtFileService.class);
            }
            return instance;
        }
    }

    /**
     * Reads a file.
     * 
     * @param path file path
     * @return file content as string
     */
    String readFile(String path);
}
